package org.cangkuguanli.luoyuhang.controller;

import org.cangkuguanli.luoyuhang.bean.Gongyingshang;
import org.cangkuguanli.luoyuhang.bean.YuanGong;
import org.cangkuguanli.luoyuhang.mapper.GongyingshangMapper;
import org.cangkuguanli.luoyuhang.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 登录接口
 */
@RestController
@RequestMapping("/gongyingshang")
public class GongyingshangController {





    @Autowired
    private GongyingshangMapper gongyingshangMapper;


    //用户登录
    @RequestMapping("/login")
    public JsonResult find(Gongyingshang user) { //参数
        System.out.println(user);
        Gongyingshang u = gongyingshangMapper.login(user);
        if (u == null) {
            // 登陆失败
            JsonResult result
                    = new JsonResult(false, 427, null, "账号或者密码错误");
            return result;
        } else {
            // 登陆成功
            JsonResult result = new JsonResult(true, 200, u, "");
            return result;
        }
    }



    //用户注册
    @RequestMapping("/register")
    public JsonResult register(Gongyingshang user) { //参数
        gongyingshangMapper.add(user);
        JsonResult result = new JsonResult(true,200,"success","");
        return result;
    }
}
